const db = wx.cloud.database()
Page({
  /**
   * 页面的初始数据
   */
  data: {
    // 轮播图图片
    slideshow: [
      '../../images/index/banner1.jpg',
      '../../images/index/banner2.jpg',
      '../../images/index/banner3.jpg',
    ],
    // 功能列表 
    functionList: [{
        text: '快递代取',
        img: '../../images/index/kuaidi.png',
        url: '../../pages/getExpress/getExpress'
      },
      {
        text: '打印服务',
        img: '../../images/index/dayin.png',
        url: '../../pages/printServe/printServe'
      },
      {
        text: '校园跑腿',
        img: '../../images/index/paotui.png',
        url: '../../pages/schoolRun/schoolRun'
      },
      {
        text: '快递代寄',
        img: '../../images/index/kuaididaiji.png',
        url: '../../pages/expressMail/expressMail'
      },
      {
        text: '租借服务',
        img: '../../images/index/zujie.png',
        url: '../../pages/borrowServe/borrowServe'
      },
      {
        text: '游戏陪玩',
        img: '../../images/index/youxi.png',
        url: '../../pages/playGameWith/playGameWith'
      },
      {
        text: '帮我送',
        img: '../../images/index/bangsong.png',
        url: '../../pages/helpMeSend/helpMeSend'
      },
      {
        text: '代替服务',
        img: '../../images/index/daiti.png',
        url: '../../pages/replaceServe/replaceServe'
      },
      {
        text: '其他帮助',
        img: '../../images/index/qita.png',
        url: '../../pages/otherHelp/otherHelp'
      },
    ]
  },
  // 显示详细信息
  detailMsg() {
    wx.showModal({
      title: '公告',
      content: '关注公众号可享订单推送-接单员请务必添加客服v:19120735045'
    })
  },
  // 跳转页面
  goPage(e) {
    const userInfo = wx.getStorageSync('userInfo')
    // 如果用户没有授权登录
    if (!userInfo){
      wx.showToast({
        title: '请先授权登录',
        icon: "none",
      })
      return
    }
    wx.navigateTo({
      url: e.currentTarget.dataset.url,
    })
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    const openId = wx.getStorageSync('openId')
    // 如果不存在openId，才会去获取
    if (!openId) {
      wx.cloud.callFunction({
        name: 'getOpenID',
        success(res) {
          const {result} = res
          const {openid} = result
          wx.setStorageSync('openId', openid)
        },
      })
    }
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})